Static Plots

Row

Histogram

boxplot

Row

Scatter Plot 1

Scatter Plot 2

Interactive Plots

Row

Histogram

Boxplot

Row

Scatter Plot 1

Interactive Maps

Row

Map 1

Map 2

Row

Map 2

---
title: "Dashboards at EVANS UW"
author: "Great student"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    social: menu
    source_code: embed # share your code?
---

```{r setup, include=FALSE}
library(flexdashboard)
###
library(ggplot2)
library(plotly)
library(plyr)
library(sf)

myWeb="https://github.com/EvansDataScience/VAforPM_Dashboard/raw/main/"
worldMap=read_sf(paste0(myWeb,"worldMap.geojson"))
SafeCityPoints=read_sf(paste0(myWeb,"SafeCityPoints.geojson"))
vars=readRDS(file=url(paste0(myWeb,"dataCSV.rds")))
worldMapVars=merge(worldMap,vars,by='ISO3')
```

Static Plots
=======================================================================

Row
-----------------------------------------------------------------------

### Histogram

```{r}
base1 = ggplot(data=vars) + theme_classic()
ps1=base1 + geom_histogram(aes(x=HDI)) 
ps1
```


### boxplot 

```{r}
ps2=base1 + geom_boxplot(aes(y= mil_expend)) 
ps2
```

Row
-----------------------------------------------------------------------

### Scatter Plot 1

```{r}
ps3=base1 + geom_point(aes(x=HDI,y= mil_expend)) 
ps3
```

### Scatter Plot 2

```{r}
ps4=base1 + geom_point(aes(x=HDI,y= DemoIndex)) 
ps4
```

Interactive Plots
=======================================================================

Row
-----------------------------------------------------------------------

### Histogram 

```{r}
pi1=base1 + geom_histogram(aes(x=HDI)) 
ggplotly(pi1)
```

### Boxplot

```{r}
pi2=base1 + geom_boxplot(aes(y=DemoIndex)) 
ggplotly(pi2)

```

Row 
-----------------------------------------------------------------------

### Scatter Plot 1

```{r}
pi3=base1 + geom_point(aes(x=HDI,y= mil_expend)) 
ggplotly(pi3)
```


Interactive Maps
=======================================================================


Row 
-----------------------------------------------------------------------

### Map 1


```{r}
#the text  aesthetics is NOt for ggplot
base2=ggplot(data=worldMap) + geom_sf(fill='grey90',color=NA) + theme_void()
colMap= base2 + geom_sf(data=worldMapVars,aes(fill=DemoIndex,
                           text=Country),
                       color=NA)

colMap=colMap + scale_fill_gradient(low = 'red',
                                    high= 'blue')
colMap%>%ggplotly()
```

### Map 2
```{r}
#the text  aesthetics is NOt for ggplot
colMap= base2 + geom_sf(data=worldMapVars,aes(fill=cluster,
                           text=Country),
                       color=NA)

colMap=colMap +  scale_fill_brewer(palette ='YlOrRd',direction = -1)
colMap%>%ggplotly()
```

Row 
-----------------------------------------------------------------------

### Map 2

```{r, eval=TRUE,warning=FALSE,message=FALSE}
basep=ggplot(data = worldMapVars) + geom_sf(fill='grey90',color=NA) + theme_bw()

points1=basep + geom_sf(data=SafeCityPoints,
                       aes(text=city))
points1%>%ggplotly()
```